﻿@model OrderDetailsModel
@using Nop.Core.Domain.Orders
@using Nop.Web.Models.Order
@using Nop.Services.Localization
@{
    Layout = "~/Views/Shared/_Root.cshtml";
    //title
    Html.AddTitleParts(T("PageTitle.OrderDetails").Text);
}
<div class="order-details">
    <div class="page-title">
        <h1>
            @T("Order.OrderInformation")</h1>
    </div>
    <div class="clear">
    </div>
    <div class="info">
        <div class="order-overview">
            <div>
                <b>@T("Order.Order#")@Model.Id</b>
            </div>
            <div>
                @T("Order.OrderDate"): @Model.CreatedOn.ToString("D")
            </div>
            <div>
                @T("Order.OrderTotal"): @Model.OrderTotal
            </div>
            <div>
                @T("Order.OrderStatus"): @Model.OrderStatus
            </div>
        </div>
        <div class="clear">
        </div>
        <div class="order-details-box">
            <div>
                <div>
                    <b>
                        @T("Order.BillingAddress")</b></div>
                <div>@Model.BillingAddress.FirstName @Model.BillingAddress.LastName</div>
                <div>
                    @T("Order.Email"): @Model.BillingAddress.Email</div>
                <div>
                    @T("Order.Phone"): @Model.BillingAddress.PhoneNumber</div>
                <div>
                    @T("Order.Fax"): @Model.BillingAddress.FaxNumber</div>
                @if (!String.IsNullOrEmpty(Model.BillingAddress.Company))
                {
                    <div>
                        @Model.BillingAddress.Company
                    </div>
                }
                <div>
                    @Model.BillingAddress.Address1</div>
                @if (!String.IsNullOrEmpty(Model.BillingAddress.Address2))
                {
                    <div>
                        @Model.BillingAddress.Address2
                    </div>
                }
                <div>
                    @Model.BillingAddress.City, @Model.BillingAddress.StateProvinceName @Model.BillingAddress.ZipPostalCode</div>
                @if (!String.IsNullOrEmpty(Model.BillingAddress.CountryName))
                {
                    <div>
                        @Model.BillingAddress.CountryName
                    </div>
                }
                @if (!String.IsNullOrEmpty(Model.VatNumber))
                {
                    <div>
                        <b>@T("Order.VATNumber")</b>
                    </div>
                    <div>
                        @Model.VatNumber
                    </div>
                }
                @if (!String.IsNullOrEmpty(Model.PaymentMethod))
                {
                    <div>
                        <b>@T("Order.PaymentMethod")</b>
                    </div>
                    <div>
                        @Model.PaymentMethod
                        @if (Model.CanRePostProcessPayment)
                        {
@*Completing payment support (for redirection payment methods)*
@*set "data-ajax" attribute to "false"*@
                            using (Html.BeginForm("Details", "Order", FormMethod.Post,
                                new Dictionary<string, Object> { { "data-ajax", "false" } }))
                            {
                            <input type="submit" name="repost-payment" value="@T("Order.CompletePayment")" id="repost-payment" />
                            <div>
                                <i>@T("Order.CompletePayment.Hint")</i>
                            </div>
                            }
                        }
                    </div>
                }
            </div>
            @if (Model.IsShippable)
            {
                <div>
                    <div>
                        <b>@T("Order.ShippingAddress")</b>
                    </div>
                    <div>
                        @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName
                    </div>
                    <div>
                        @T("Order.Email"): @Model.ShippingAddress.Email</div>
                    <div>
                        @T("Order.Phone"): @Model.ShippingAddress.PhoneNumber</div>
                    <div>
                        @T("Order.Fax"): @Model.ShippingAddress.FaxNumber</div>
                    @if (!String.IsNullOrEmpty(Model.ShippingAddress.Company))
                    {
                        <div>
                            @Model.ShippingAddress.Company
                        </div>
                    }
                    <div>
                        @Model.ShippingAddress.Address1</div>
                    @if (!String.IsNullOrEmpty(Model.ShippingAddress.Address2))
                    {
                        <div>
                            @Model.ShippingAddress.Address2
                        </div>
                    }
                    <div>
                        @Model.ShippingAddress.City, @Model.ShippingAddress.StateProvinceName @Model.ShippingAddress.ZipPostalCode</div>
                    @if (!String.IsNullOrEmpty(Model.ShippingAddress.CountryName))
                    {
                        <div>
                            @Model.ShippingAddress.CountryName
                        </div>
                    }
                    <div>
                        <b>
                            @T("Order.ShippingMethod")</b>
                    </div>
                    <div>
                        @Model.ShippingMethod
                    </div>
                    <div>
                        <b>
                            @T("Order.Weight")</b>
                    </div>
                    <div>
                        @string.Format("{0:F2} [{1}]", Model.OrderWeight, Model.BaseWeightIn)
                    </div>
                </div>
            }
        </div>
        <div class="clear">
        </div>
        @if (Model.Items.Count > 0)
        {
            <div class="section-title">
                @T("Order.Product(s)")</div>
            <div class="clear">
            </div>
            
            <ul data-role="listview" data-inset="true" data-filter="false">
                @foreach (var item in Model.Items)
                {
                    <li>
                        <div class="products-box">
                            <div class="product">
                                <b><a href="@Url.RouteUrl("Product", new { productId = item.ProductId, SeName = item.ProductSeName })" title="View details">@item.ProductName</a></b>
                                @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                {
                                    <br />
                                    @Html.Raw(item.AttributeInfo)
                                }
                            </div>
                            @if (Model.ShowSku && !string.IsNullOrEmpty(item.Sku))
                            {
                                <div class="sku">
                                    @T("Order.Product(s).SKU"): @item.Sku
                                </div>
                            }
                            <div class="unitprice">
                                @T("Order.Product(s).Price"): @item.UnitPrice
                            </div>
                            <div class="qty">
                                @T("Order.Product(s).Quantity"): @item.Quantity
                            </div>
                            <div class="subtotal">
                                @T("Order.Product(s).Total"): @item.SubTotal
                            </div>
                        </div>
                    </li>
                }
            </ul>
                if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
                {
            <div class="checkout-attributes">
                @Html.Raw(Model.CheckoutAttributeInfo)
            </div>
            <div class="clear">
            </div>
                }
@*Reorder support*@
                if (Model.IsReOrderAllowed)
                {
            <a href="@Url.RouteUrl("ReOrder", new { orderId = @Model.Id })" data-role="button">@T("Order.Reorder")</a>
                }
                if (Model.IsReturnRequestAllowed)
                {
            <a href="@Url.RouteUrl("ReturnRequest", new { orderId = @Model.Id })" data-role="button">@T("Order.ReturnItems")</a>
                }
            <div class="clear">
            </div>
        }
        <div class="total-info">
            <table class="cart-total">
                <tbody>
                    <tr>
                        <td class="cart_total_left">
                            <b>
                                @T("Order.SubTotal"):</b>
                        </td>
                        <td class="cart_total_right">
                            <span class="nobr">
                                @Model.OrderSubtotal
                            </span>
                        </td>
                    </tr>
                    @if (!string.IsNullOrEmpty(Model.OrderSubTotalDiscount))
                    {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @T("Order.SubTotalDiscount"):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @Model.OrderSubTotalDiscount
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.IsShippable)
                    {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @T("Order.Shipping"):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @Model.OrderShipping
                                </span>
                            </td>
                        </tr>
                    }
                    @if (!string.IsNullOrEmpty(Model.PaymentMethodAdditionalFee))
                    {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @T("Order.PaymentMethodAdditionalFee"):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @Model.PaymentMethodAdditionalFee
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.DisplayTaxRates && Model.TaxRates.Count > 0)
                    {
                        foreach (var taxRate in Model.TaxRates)
                        {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @string.Format(T("Order.TaxRateLine").Text, taxRate.Rate):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @taxRate.Value
                                </span>
                            </td>
                        </tr>
                        }
                    }
                    @if (Model.DisplayTax)
                    {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @T("Order.Tax"):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @Model.Tax
                                </span>
                            </td>
                        </tr>
                    }
                    @if (!string.IsNullOrEmpty(Model.OrderTotalDiscount))
                    {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @T("Order.TotalDiscount"):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @Model.OrderTotalDiscount
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.GiftCards.Count > 0)
                    {
                        foreach (var gc in Model.GiftCards)
                        {
                        <tr>
                            <td class="cart_total_left">
                                <b>
                                    @string.Format(T("Order.GiftCardInfo").Text, gc.CouponCode):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @gc.Amount
                                </span>
                            </td>
                        </tr>
                        }
                    }
                    @if (Model.RedeemedRewardPoints > 0)
                    {
                        <tr>
                            <td class="cart_total_left">
                                <b>@string.Format(T("Order.RewardPoints").Text, Model.RedeemedRewardPoints):</b>
                            </td>
                            <td class="cart_total_right">
                                <span class="nobr">
                                    @Model.RedeemedRewardPointsAmount
                                </span>
                            </td>
                        </tr>
                    }
                    <tr>
                        <td class="cart_total_left">
                            <b>
                                @T("Order.OrderTotal"):</b>
                        </td>
                        <td class="cart_total_right">
                            <b><span class="nobr">
                                @Model.OrderTotal
                            </span></b>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="clear">
        </div>
        @if (Model.Shipments.Count > 0)
        {
            <div class="section-title">
                @T("Order.Shipments")
            </div>                
            <ul data-role="listview" data-inset="true" data-filter="false">
                @foreach (var item in Model.Shipments)
                {      
                    <li>
                        <div class="shipments-box">
                            <div>@T("Order.Shipments.ID"): @item.Id.ToString()</div>
                            <div>@T("Order.Shipments.TrackingNumber"): @item.TrackingNumber</div>
                            <div>@T("Order.Shipments.ShippedDate"): @item.ShippedDate.ToString("D")</div>
                            <div>@T("Order.Shipments.DeliveryDate"):
                                @if (item.DeliveryDate.HasValue)
                                {
                                    @item.DeliveryDate.Value.ToString("D")
                                }
                                else
                                {
                                    @T("Order.Shipments.DeliveryDate.NotYet")
                                }
                            </div>
                            <div>
                                <a href="@Url.RouteUrl("ShipmentDetails", new { shipmentId = item.Id })">@T("Order.Shipments.ViewDetails")</a></div>
                        </div>
                    </li>
                }
            </ul>
        }
        <div class="clear">
        </div>
        @if (Model.OrderNotes.Count > 0)
        {
            <div class="section-title">
                @T("Order.Notes")
            </div>                
            <ul data-role="listview" data-inset="true" data-filter="false">
                @foreach (var item in Model.OrderNotes)
                {      
                    <li>
                        <div class="ordernotes-box">
                            <div>@T("Order.Notes.CreatedOn"): @item.CreatedOn.ToString()</div>
                            <div>@T("Order.Notes.Note"): @Html.Raw(item.Note)</div>
                        </div>
                    </li>
                }
            </ul>
        }
    </div>
</div>
